/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package naivebayes;

import TextManager.Vocabulary;
import TextManager.WordOccurrence;
import TextManager.WordOccurrencesMap;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Jaime
 */
public class DocumentsGroup{
    
    private WordOccurrencesMap positiveTextWords;
    private WordOccurrencesMap negativeTextWords;
    private Vocabulary vocabulary;
    private List<File> positiveFiles;
    private List<File> negativeFiles;
    
    
    public DocumentsGroup(Vocabulary vocabulary)
    {
       
        
        this.vocabulary = vocabulary;
        positiveTextWords = new WordOccurrencesMap(vocabulary);
        negativeTextWords = new WordOccurrencesMap(vocabulary);
        positiveFiles = new ArrayList<File>();
        negativeFiles = new ArrayList<File>();
    }
    
    public void addFile(File file, boolean positive)
    {
        if(positive)
        {
            getPositiveFiles().add(file);
        }
        else
        {
            getNegativeFiles().add(file);
        }
    }
    
    public void addPositiveWord(WordOccurrence word)
    {
        positiveTextWords.newOccurrence(word);
    }
    
    public void addNegativeWord(WordOccurrence word)
    {
        negativeTextWords.newOccurrence(word);
    }

    public int getNumberOfPositiveWords()
    {
        return positiveTextWords.size();
    }
    
    public int getNumberOfNegativeWords()
    {
        return negativeTextWords.size();
    }
    
    public int getNumberOfWords()
    {
        return getNumberOfPositiveWords() + getNumberOfNegativeWords();
    }
    
    public int getNumberOfPositiveOccurrences(WordOccurrence word)
    {
        return positiveTextWords.getNumberofOccurrences(word);
    }
    
    public int getNumberOfNegativeOccurrences(WordOccurrence word)
    {
        return negativeTextWords.getNumberofOccurrences(word);
    }
    
    public int getNumberOfOccurrences(WordOccurrence word)
    {
        return getNumberOfPositiveOccurrences(word) + getNumberOfNegativeOccurrences(word);
    }
    
    public int getNumberOfPositiveOccurrences()
    {
        return positiveTextWords.getNumberWordOccurrences();
    }
    
    public int getNumberOfNegativeOccurrences()
    {
        return negativeTextWords.getNumberWordOccurrences();
    }
    
    public String toString()
    {
        String ret = "Group:\nPositives:\n"+
                positiveTextWords.size()+"\nNegatives:\n"+negativeTextWords.size()+"\n";
        return ret;
    }

    /**
     * @return the positiveFiles
     */
    public List<File> getPositiveFiles() {
        return positiveFiles;
    }

    /**
     * @return the negativeFiles
     */
    public List<File> getNegativeFiles() {
        return negativeFiles;
    }



    
}
